## OVERVIEW

The code in this replication package conducts the analysis for the article 
"Gendered Perceptions and the Costs of Political Toxicity: Experimental Evidence 
from Politicians and Contents Citizens in Four Democracies". All code is in R. 
Three .R files run the code necessary to generate the figures and tables in the 
main article and in the appendix. The raw data are also provided to show 
transparently how the cleaned data were generated. No file will take a
substantial amount of time to run.


## DATA AVAILABILITY

Raw micro-data that indicate the party of politician respondents (which is used 
only for Tables C11-C13 regarding representativeness) are coarsened to ensure 
the anonymity of the politician respondents. Raw micro-data that indicate 
whether a politician respondent is a local politician or national politician are 
also excluded to ensure anonymity (only necessary for Appendix Figure K13, and 
footnote 7 in the main article). Data necessary for all other tables, figures, 
and statistics in the article and appendix are provided.


## FILES

  ./CivicPulse Reference Guide 2022-10-21.pdf
  Survey data from US politicians were collected through the survey firm
  CivicPulse. This file provides the codebook for the CivicPulse raw data, and
  the sample and population statistics for the data (end of the PDF), that are
  then shown in Table C10 of the Appendix.

  ./Ethics Approval 2022-005.pdf
  Ethics approval from the University of Copenhagen for the experiment.

  ./Survey_Questions_Citizens.pdf
  Codebook for the survey data for the citizen surveys (taken from Qualitrics).

  ./Survey_Questions_Politicians.pdf
  Codebook for the survey data for the politician surveys (taken from
  Qualitrics).

  ./Appendix.pdf
  Appendix to the article, which contains description of the data collection

  ./Figures/
  Files in this directory are those that are used in the main article and in the
  appendix. One can thus compare these to those outputted from the replication
  script.


## DATASET LIST

The following data are provided in the replication archive:

  # CLEANED DATA:

  ./Data/Paired_Conjoint_Data.rds
  Cleaned data from the paired conjoint design, including responses from both
  politician and citizen respondents.

  ./Data/Vignette_Data.rds
  Cleaned data from the single vignette design, including  responses from both
  politician and citizen respondents.

  ./Data/Citizen_Population_Values.rds
  ./Data/Politician_Population_Values.rds
  Population values of the socio-demographic characteristics of the public and
  politicians in each of the 4 countries examined. Used to examine sample
  representativeness.

  Data in the ./Data_Cleaned/ directory are intermediary files that are created
  in the cleaning process going from the raw to the cleaned data. They are not
  themselves used in the analysis.


  # RAW DATA:

  ./Data_Raw/Chile_Background_data.csv
  Raw data that were compiled by the authors indicating the politicians in the
  sampling frame in Chilean national and local office. These data do not include
  the politician's names or email, and are only used to calculate the population
  values of representatives in Chile to compare to the sample.

  ./Data_Raw/country_psid_1.csv
  ./Data_Raw/country_psid_2.csv
  ./Data_Raw/country_psid_3.csv
  Three files provided by Dynata (survey firm) that indicate the education
  variable as recorded by Dyanta itself. These education variables are merged
  into the survey data from citizens in each of the countries. These files are
  used in the R scripts to clear the raw data (i.e. the files in 
  ./Code_Raw_Data/)

  ./Data_Raw/DK Pop Data.csv
  Raw data that were compiled by the authors indicating the politicians in the
  sampling frame in Danish national and local office.

  ./Data_Raw/Citizen Survey ORD-727620-B4X7 overview.xlsx
  Raw data from the survey firm Dynata indicating the socio-demographic
  population statistics for the citizens in the four countries, for use to
  compare sample to population statistics

  ./Data_Raw/RAW-US+Citizen+Survey_November+4%2C+2022_08.08.csv
  ./Data_Raw/RAW-Belgium+Citizen+Survey_September+29%2C+2022_03.08.csv
  ./Data_Raw/RAW-Chile+Citizen+Survey_December+11%2C+2022_12.53.csv
  ./Data_Raw/RAW-Chile+Politician+Survey+-+Spanish_June+16%2C+2022_03.09.csv
  ./Data_Raw/RAW-CivicPulse Rasmussen Data 2022-10-21.csv
  ./Data_Raw/RAW-DK.csv
  ./Data_Raw/RAW-DK+Citizen+Survey_September+29%2C+2022_02.57.csv
  ./Data_Raw/RAW-Flanders.dta
  These files are the raw survey data out of Qualitrics (and from CivicPulse in
  US). All variables are included that are necessary for the analysis in the
  article. Because politicians are a small population in each country, two
  variables in the raw data have been modified. The political party variable for
  each politician is coarsened and whether the politician is at at local or
  national level is NA'd out. These variables are only necessary to calculate
  representativeness statistics (Tables C11-C13 in Appendix C); to produce
  Appendix Figure K13 (local versus national politician effects sizes); and 
  descriptive statistics about the extent that national and local politicians
  report facing toxic behavior online (footnote 7). Fortunately, none of these
  are central to the main analysis itself.




## DESCRIPTION OF PROGRAMS/CODE

  ./ggplot_theme.R
  A ggplot2 theme that is loaded from each of the analysis R files below.

  
  # MAIN ANALYSIS

  The following three files conduct all of the analysis for the article from the
  cleaned data that are found in ./Data/. Unless one wants to examine the
  process of cleaning the raw data, these three files are all one needs to look
  at. All figures and tables are labeled at the relevant part of the the code
  (e.g. "TABLE C11", "FIGURE 1", "FIGURE E6") so that replicators can easily 
  search for any specific item to replicate in the three R files below. These
  files can be run in any order.

  ./1_Descriptives.R
  Computes all Figures, Tables, and statistics regarding the sample and 
  representativeness
  - Figure D1
  - Tables C6, C7, C8, C9, C11, C12, C13

  ./2_Paired_Conjoint_Analysis.R
  Computes all Figures, Tables, and statistics concerning the paired conjoint
  analysis:
  - Figures 3, 4, 5, E2, E3, E4, E5, I10, J11, K13, L14, M15, M16
  - Tables N15, N16, N17, N18

  ./3_Vignette_Analysis.R
  Computes all Figures, Tables, and statistics concerning the single vignette
  analysis
  - Figure 6, 7, E6, F7, H8, H9, J12
  - Table G14, N19, N20, N21


  # RAW DATA CLEANING SCRIPTS

  Note: To compile from the raw data, run files 1_*.R first, then 
  2_Population_Data.R, then 3_Merge_Country_Data.R.

  ./Code_Raw_Data/1_BE_Citizen.R
  ./Code_Raw_Data/1_BE_Politician.R
  ./Code_Raw_Data/1_CL_Citizen.R
  ./Code_Raw_Data/1_CL_Politician.R
  ./Code_Raw_Data/1_DK_Citizen.R
  ./Code_Raw_Data/1_DK_Politician.R
  ./Code_Raw_Data/1_US_Citizen.R
  ./Code_Raw_Data/1_US_Politician.R
  These files clean the raw data for each of the four countries for citizens and
  for politicians. They can be run in any order and produce the intermediary 
  files found in ./Data_Cleaned/ for each country.

  ./Code_Raw_Data/2_Population_Data.R
  Takes the population tables provided by the survey firm and create cleaned
  data concerning the population statistics of those in each of the four
  countries. Produces the file ./Data/Politician_Population_Values.rds and
  ./Data/Citizen_Population_Values.rds

  ./Code_Raw_Data/3_Merge_Country_Data.R
  Takes the intermediary files found in ./Data_Cleaned/ and merges them
  together into a cleaned data file for all countries for the vignette data
  (./Data/Vignette_Data.rds), and for all countries for the paired conjoint
  data (./Data/Paired_Conjoint_Data.rds)


## R LIBRARIES

  R (4.4.0)
    - ggh4x: 0.2.8
    - tidyverse: 2.0.0
    - stringr: 1.5.1
    - modelsummary: 2.1.1
    - kableExtra: 1.4.0
    - cowplot: 1.1.3
    - grid: 4.4.0
    - gridExtra: 2.3
    - scales: 1.3.0
    - ggforce: 0.4.2
    - cjoint: 2.1.1
    - fixest: 0.12.1
    - broom: 1.0.6
    - lfe: 3.0.0
    - haven: 2.5.4
    - cregg: 0.4.0 [No longer on CRAN. Install with:
                    remotes::install_github("leeper/cregg")]
